package message

import (
	jsoniter "github.com/json-iterator/go"
)

type Source struct {
	Service string `json:"sn,omitempty"`  //服务名称
	Session string `json:"sid,omitempty"` //服务点
	Clerk   string `json:"cid,omitempty"` //服务员
}

func (ts *Source) E3LogMarshall() string {
	out, _ := jsoniter.ConfigFastest.MarshalToString(ts)
	return out
}
func (ts *Source) Copy() *Source {
	return &Source{
		Service: ts.Service,
		Session: ts.Session,
		Clerk:   ts.Clerk,
	}
}

func (ts *Source) Clone(src Source) {
	ts.Service = src.ServiceID()
	ts.Session = src.SessionID()
	ts.Clerk = src.ClerkID()
}

func (ts *Source) ServiceID() string {
	return ts.Service
}

func (ts *Source) SessionID() string {
	return ts.Session
}

func (ts *Source) ClerkID() string {
	return ts.Clerk
}

func (ts *Source) Clean() {
	ts.Service = ""
	ts.Session = ""
	ts.Clerk = ""
}

func (ts *Source) FromJson(js string) error {
	return jsoniter.ConfigFastest.UnmarshalFromString(js, ts)
}

func (ts *Source) ToJson() string {
	js, _ := jsoniter.ConfigFastest.MarshalToString(ts)
	return js
}
